package com.restaurant.springboot.repositories;

import com.github.pagehelper.Page;
import com.restaurant.springboot.entity.DishesEntity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface DishesRepository extends JpaRepository<DishesEntity,Integer> {

    @Modifying
    @Transactional
    @Query(value = "DELETE FROM dishes WHERE dishes_series_id=:dishesSeriesId",nativeQuery = true   )
    void deleteAllDishesByDishesSeriesId(@Param("dishesSeriesId") int dishesSeriesId);

    List<DishesEntity> findAllByDishesSeriesId(int dishesSeriesId);

    void deleteById(int dishesId);

    List<DishesEntity> findAllByState(int state);

}